<?php

include "config.php";
$filepath=$_GET["filepath"];
$username=$_GET["username"];
//echo $filepath."<br/>".$username."<br/>";

		$query = "SELECT annotations.id, votes_up, votes_down
					FROM annotations, users, images
					WHERE images.file_path =  '$filepath'
					AND annotations.user_id = users.id
					AND users.username = '$username'
					AND images.id = annotations.image_id";
		$result = mysql_query($query);
		if (mysql_num_rows($result) == 0) {
		echo "<h3>No images to be diagnosed. Click <a href='welcome.php'>here</a> to go back</h3>";
		}
		while($row = mysql_fetch_array($result))
		{
			$arr = array('votes_up' => $row['votes_up'], 'votes_down' => $row['votes_down'], 'id' => $row['id']);
			echo json_encode($arr);
		}

		mysql_close($con);

?>